<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class CI_Escort_user_roles_n_benefits_entity{
	var $current_dbprefix = "";
	var $id = '';
	var $username = '';
	var $password = '';
	var $group = 0;
	var $name = '';
	var $phone = '';
	var $email = '';
	var $address = '';
	var $wallet = 0;
	var $comission = 0;
	var $updated_time = 0;
	var $status = 0;
		
	function __construct() {
		$ci= & get_instance();
		$this->current_dbprefix = $ci->db->dbprefix;
		$ci->db->set_dbprefix('default_');
	}
	function __destruct() {
		$ci= & get_instance();
		$ci->db->set_dbprefix($this->current_dbprefix);
	}
	function setId($input){
		$this->id=$input;
	}
	function setUserName($input){
		$this->username=$input;
	}
	function setPassword($input){
		$this->password=$input;
	}
	function setGroup($input){
		$this->group = $input;
	}
	function setName($input){
		$this->name = $input;
	}
	function setPhone($input){
		$this->phone = $input;
	}
	function setEmail($input){
		$this->email = $input;
	}
	function setAddress($input){
		$this->address = $input;
	}
	function setWallet($input){
		$this->wallet = $input;
	}
	function setComission($input){
		$this->comission = $input;
	}
	
	function setUpdatedTime($input){
		$this->updated_time= $input;
	}
	function setStatus($input){
		$this->status = $input;
	}
	
	function getId(){
		return $this->id;
	}
	function getUserName(){
		return $this->username;
	}
	function getPassword(){
		return $this->password;
	}
	function getGroup(){
		return $this->group;
	}
	function getName(){
		return $this->name;
	}
	function getPhone(){
		return $this->phone;
	}
	function getEmail(){
		return $this->email;
	}
	function getAddress(){
		return $this->address;
	}
	function getWallet(){
		return $this->wallet;
	}
	function getComission(){
		return $this->comission;
	}
	function getUpdatedTime(){
		return $this->updated_time;
	}
	function getStatus(){
		return $this->status;
	}
	
	function init($cmd, $input)
	{
		$ci=& get_instance();
		if($cmd == 'username')
		{
			$result = $ci->db->where('username',$input)->get(TBL_ESCORT_USER_ROLES_N_BENEFITS)->result();
		}else if($cmd = 'id'){
			$result = $ci->db->where('id',$input)->get(TBL_ESCORT_USER_ROLES_N_BENEFITS)->result();
		}else{
			return false;
		}
		if( !empty($result) )
		{
			$this->id = $result[0]->id;
			$this->username = $result[0]->username;
			$this->password = $result[0]->password;
			$this->group = $result[0]->group;
			$this->name = $result[0]->name;
			$this->phone = $result[0]->phone;
			$this->email = $result[0]->email;
			$this->address = $result[0]->address;
			$this->wallet = $result[0]->wallet;
			$this->comission = $result[0]->comission;
			$this->updated_time = $result[0]->updated_time;
			$this->status = $result[0]->status;
			return $this;
		}
		return false;
	}
	
	function getUserRolesNBenefits($username){
		$ci=& get_instance();
		$ci->db->where('username',$username);
		return $ci->db->get(TBL_ESCORT_USER_ROLES_N_BENEFITS)->result();
	}
		
	function save(){
		$ci=& get_instance();
		$ci->db->set('username',$this->getUserName());
		$ci->db->set('password',$this->getPassword());
		$ci->db->set('group',$this->getGroup());
		$ci->db->set('name',$this->getName());
		$ci->db->set('phone',$this->getPhone());
		$ci->db->set('email',$this->getEmail());
		$ci->db->set('address',$this->getAddress());
		$ci->db->set('wallet',$this->getAddress());
		$ci->db->set('comission',$this->getComission());
		$ci->db->set('updated_time',$this->getUpdatedTime());
		$ci->db->set('status',$this->getStatus());
		$ci->db->insert(TBL_ESCORT_USER_ROLES_N_BENEFITS);
		return $ci->db->insert_id();
	}
	function update(){
		$ci=& get_instance();
		$ci->db->set('username',$this->getUserName());
		$ci->db->set('password',$this->getPassword());
		$ci->db->set('group',$this->getGroup());
		$ci->db->set('name',$this->getName());
		$ci->db->set('phone',$this->getPhone());
		$ci->db->set('email',$this->getEmail());
		$ci->db->set('address',$this->getAddress());
		$ci->db->set('wallet',$this->getWallet());
		$ci->db->set('comission',$this->getComission());
		$ci->db->set('updated_time',$this->getUpdatedTime());
		$ci->db->set('status',$this->getStatus());
		return $ci->db->where('id', $this->id)->update(TBL_ESCORT_USER_ROLES_N_BENEFITS);
	}
	function delete($id){
		$ci=& get_instance();
		$ci->db->where('id',$id);
		$ci->db->delete(TBL_ESCORT_USER_ROLES_N_BENEFITS);
	}
}